package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import entity.SurveyDetail;

public class SurveyDetailDao extends SqlBase<SurveyDetail> {
	private Connection conn;

	public SurveyDetailDao() {
		conn = DBUtile.getConnection();
	}

	public List<SurveyDetail> getScoreAndContent(Integer id) {
		List<SurveyDetail> sds = new ArrayList<>();
		String sql = "SELECT content_id,score FROM surveydetail WHERE INFO_ID=?";
		try {
			PreparedStatement pstm = conn.prepareStatement(sql);
			pstm.setInt(1, id);
			ResultSet rs = pstm.executeQuery();
			while (rs.next()) {
				SurveyDetail sd = new SurveyDetail();
				sd.setContent_Id(rs.getInt("content_id"));
				sd.setScore(rs.getInt("score"));
				sds.add(sd);

			}

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return sds;
	}
}
